﻿package mortal.game.view.vip.panel
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import extend.language.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class VipCompareRender extends GCellRenderer
    {
        private var _privilegeName:GTextFiled;
        private var _levelPrivilegeList:Vector.<IFrUI>;
        private var _tvip:TVip;
        private var _bg:GImageBitmap;

        public function VipCompareRender()
        {
            this._levelPrivilegeList = new Vector.<IFrUI>;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gImageBitmap("", 0, 0, this);
            var _loc_1:* = GlobalStyle.textFormatHuang2.center();
            _loc_1.size = 13;
            this._privilegeName = UIFactory.gTextField("", 0, 6, 120, 25, this, _loc_1);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._privilegeName.dispose(param1);
            this._privilegeName = null;
            this._bg.dispose(param1);
            this._bg = null;
            this._tvip = null;
            this.clearList();
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._tvip = param1.tvip as TVip;
            var _loc_2:* = param1.index;
            this._bg.imgUrl = "VipCompareBg" + ((_loc_2 + 1) % 2 + 1);
            if (this._tvip.desc)
            {
                this._privilegeName.text = this._tvip.desc;
            }
            this.updatePrivilegeList();
            return;
        }// end function

        private function updatePrivilegeList() : void
        {
            var _loc_1:int = 0;
            var _loc_2:int = 0;
            var _loc_3:GImageBitmap = null;
            var _loc_4:GTextFiled = null;
            var _loc_5:String = null;
            var _loc_6:GTextFormat = null;
            var _loc_7:int = 0;
            this.clearList();
            if (this._tvip.showType == 2)
            {
                _loc_2 = 1;
                while (_loc_2 <= 10)
                {
                    
                    _loc_1 = int(this._tvip["vip" + _loc_2]);
                    _loc_3 = UIFactory.gImageBitmap("", _loc_2 * 75 + 67, 2, this);
                    if (_loc_1)
                    {
                        _loc_3.imgUrl = ImagesConst.VipHasIcon;
                    }
                    else
                    {
                        _loc_3.imgUrl = ImagesConst.VipHasNoIcon;
                    }
                    this._levelPrivilegeList.push(_loc_3);
                    _loc_2++;
                }
            }
            else
            {
                _loc_6 = GlobalStyle.textFormatItemGreen.center();
                _loc_6.size = 13;
                _loc_7 = 1;
                while (_loc_7 <= 10)
                {
                    
                    _loc_1 = int(this._tvip["vip" + _loc_7]);
                    if (this._tvip.showType == 0)
                    {
                        if (_loc_1 > 0)
                        {
                            _loc_5 = "+" + _loc_1;
                        }
                        else if (_loc_1 == -1)
                        {
                            _loc_5 = Language.getString(35583);
                        }
                        else if (_loc_1 == 0)
                        {
                            _loc_5 = "";
                        }
                    }
                    else if (this._tvip.showType == 1)
                    {
                        if (_loc_1 > 0)
                        {
                            _loc_5 = "+" + _loc_1 + "%";
                        }
                        else if (_loc_1 == 0)
                        {
                            _loc_5 = "";
                        }
                    }
                    _loc_4 = UIFactory.gTextField(_loc_5 + "", _loc_7 * 75 + 60, 6, 50, 25, this, _loc_6);
                    this._levelPrivilegeList.push(_loc_4);
                    _loc_7++;
                }
            }
            return;
        }// end function

        private function clearList() : void
        {
            var _loc_1:IFrUI = null;
            for each (_loc_1 in this._levelPrivilegeList)
            {
                
                _loc_1.dispose();
            }
            this._levelPrivilegeList.length = 0;
            return;
        }// end function

    }
}
